package cn.lyl.basic.listener;

import cn.lyl.sys.service.IPermissionService;
import cn.lyl.sys.service.impl.PermissionServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class PermissonScanInitListener implements ServletContextListener {
    @Autowired
    private IPermissionService permissionService;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        //扫描我们的自定义注解：获取name和sn
        //扫描每个接口类：1.类上的RequestMapping  2.每个方法上XxxMapping
        //System.out.println("上下文对象创建成功");
        new Thread(new Runnable() {
            @Override
            public void run() {
                permissionService.scanPermission();
            }
        }).start();

    }
}
